/*
 * Copyright (C) 2010, Funcom AS, All Rights Reserved
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  @authors
 *  Svein Gunnar Larsen <sveingunnarlarsen@gmail.com>
 *  Erik Thune Lund <culex.eriklund@gmail.com>
 *  Michel Krohn-Dale <kronicz@gmail.com>
 */

package com.funcom.peeler.tool;

import com.funcom.peeler.WorkBench;

import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

public class MultiTool extends Tool {

    MoveTool moveTool = new MoveTool( workbench );
    ResizeTool resizeTool = new ResizeTool( workbench );
    SelectTool selectTool = new SelectTool( workbench );

    public MultiTool( WorkBench workbench ) {
        super( workbench );
    }

    public void keyPressed( KeyEvent e ) {

        switch( e.getKeyCode() ) {

           case KeyEvent.VK_CONTROL: {
               workbench.pushTool(selectTool);
               break;
           }

           case KeyEvent.VK_SHIFT: {
               workbench.pushTool( resizeTool );
               break;
           }

           default:
               workbench.pushTool( moveTool );
               moveTool.keyPressed( e );
               break;
        }
    }

    public void mousePressed( MouseEvent e ) {

        switch( e.getButton() ) {

            case MouseEvent.BUTTON1: {
                if(e.isControlDown()) {
                    workbench.pushTool( selectTool );
                    selectTool.mousePressed(e);
                    break;
                }
                workbench.pushTool( moveTool );
                moveTool.mousePressed( e );
                break;
            }
        }
    }
}
